import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

public class TestSort {

    public static void main(String[] args) {
        //System.out.print("请输入创建数组的大小: ");
        Scanner scanner = new Scanner(System.in);
        //int k = scanner.nextInt();
        int[] array1 = createArray1(10);
        int[] array2 = createArray2(10);

        disPlay(array1);
        //Sort.selectSort2(array1);

        //Sort.heapSort(array1);
        //Sort.bubbleSort(array1);

        //Sort.quickSort2(array1);
        Sort.countSort(array1);
        disPlay(array1);
        //disPlay(array2);
        //Sort.shellSort(array1);

        //Sort.selectSort(arr

        //System.out.print("无序的情况下:");
        //testInsertSort(array1);
        //testShellSort(array1);

        //System.out.print("有序的情况下:");
        //testInsertSort(array2);
        //testShellSort(array2);

    }
    public static void testShellSort(int[] array){
        long startTime = System.currentTimeMillis();
        Sort.shellSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("希尔排序耗时: "+(endTime-startTime));
    }
    public static void testInsertSort(int[] array){
        long startTime = System.currentTimeMillis();
        Sort.insertSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("直接插入排序耗时: "+(endTime-startTime));
    }
    /**
     * 随机生成大小为K的数组
     * @param k
     * @return
     */
    public static int[] createArray1(int k){
        int[] arr = new int[k];
        Random random = new Random();
        for (int i = 0; i < arr.length; i++) {
            arr[i] = random.nextInt(10000);
        }
        return arr;
    }
    public static int[] createArray2(int k){
        int[] arr = new int[k];
        for (int i = 0; i < k; i++) {
            arr[i] = i;
        }
        return arr;
    }

    public static void disPlay(int[] array){
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i]+" ");
        }
        System.out.println();
    }


}
